package com.baibei.order.settlement;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.baibei.basic.IPresenter;
import com.baibei.model.OrderInfo;
import com.baibei.module.AppRouter;
import com.baibei.module.BasicActivity;
import com.baibei.order.R;
import com.baibei.order.R2;
import com.rae.swift.Rx;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 补款取货状态
 * Created by ChenRui on 2017/8/11 0011 19:03.
 */
@Route(path = AppRouter.ROUTER_SETTLEMENT_STATUS)
public class SettlementStatusActivity extends BasicActivity {

    @BindView(R2.id.tv_product_name)
    TextView mProductName;
    @BindView(R2.id.tv_quantity)
    TextView mQuantity;
    @BindView(R2.id.tv_amount)
    TextView mAmount;
    @BindView(R2.id.tv_time)
    TextView mTime;
    @BindView(R2.id.tv_status)
    TextView mStatus;
    private OrderInfo mOrderInfo;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_settlement_status);
        ButterKnife.bind(this);
        mOrderInfo = getIntent().getParcelableExtra("orderInfo");
        if (mOrderInfo != null) {
            onLoadOrderInfo(mOrderInfo);
        }
    }

    public void onLoadOrderInfo(OrderInfo orderInfo) {
        mProductName.setText(orderInfo.getName());
        mQuantity.setText(getString(R.string.format_remain_count, orderInfo.getCount())); // 数量
        mAmount.setText(Rx.formatPrice(orderInfo.getBuyMoney())); // 订金
        mTime.setText(getIntent().getStringExtra("time"));
        mStatus.setText(getIntent().getStringExtra("status"));
    }

    @Override
    public IPresenter getBasicPresenter() {
        return null;
    }

    @OnClick(R2.id.btn_finish)
    public void onFinishClick() {
        AppRouter.routeToOrderCenter(this);
        setResult(RESULT_OK);
        finish();
    }
}
